home *** CD-ROM | disk | FTP | other *** search
Wrap
property columns, rows, cellHeight, cellWidth, NW, n, NE, w, E, SW, s, SE, moveList, truck1, roadTile1, river1, bridge1, rockTile, treeTile, valleyTile, partialTileList, cellHalfH, cellHalfV, gridLeft, gridTop, cellList, pathList, startCell, goalCell, dummyBitmap, scenarioList, recordedMoveList, blockedCellObj, firstNavButtonChan, demoButChan, dataCounter, simDataString, scenarioData, returnVehicle, sandboxChan, scenarioSong, gridSprite, firstSurroundSprite, underTruckSprite, destinationSprite, stampSprite, truckSprite, obstacleState, arrowList, deltaList, convertList, demoFlag, startSimFlag, simButtonList, finishedFlag, adjList, tileList, riverList, bridgeList, gridSize, covList, invisibleButtonList, firstInvisButChan, invisibleButCover, invisibleButHiliteChan, invisibleButHiliteBmap, cellTypeList, firstTime, buildingsConnected, paver1, bus1, car1 global gActorList, gTruckObject, gGasGaugeObject, gUserObject, gLevelObject, gMenuObject, gAwardsObject, gRollAnimButton, gCDpath, gFileSep on birth me set scenarioList to [["house1", "house2", "library", "police", "store", "school", "bus", "PTW1"], ["house1", "store", "house2", "firehouse", "circus", "barn", "car", "PTW2"], ["house2", "house1", "bowling", "barn", "school", "library", "bus", "PTW3"], ["school", "library", "park", "police", "firehouse", "circus", "bus", "PTW4"], ["house1", "house2", "store", "police", "circus", "park", "car", "PTW5"], ["house2", "library", "house1", "firehouse", "store", "bowling", "car", "PTW6"]] set scenarioSong to EMPTY set firstTime to 1 set simButtonList to [:] set firstInvisButChan to 2 set gridSprite to 10 set firstSurroundSprite to 11 set invisibleButtonList to [0, 0, 0, 0, 0, 0, 0, 0] set invisibleButCover to 19 set invisibleButHiliteChan to 43 set underTruckSprite to 20 set destinationSprite to 21 set stampSprite to 22 set truckSprite to 23 set sandboxChan to 27 set firstNavButtonChan to 33 set demoButChan to 41 set gridSize to "Large" set recordedMoveList to [] set buildingsConnected to 0 set obstacleState to EMPTY set cellTypeList to [#BG, #Road, #immovable, #Rocks, #Valley, #River, #Bridge, #Building, #Goal] set arrowList to [#n, #NE, #E, #SE, #s, #SW, #w, #NW] set deltaList to [#n: [0, -1], #NE: [2, -1], #E: [2, 0], #SE: [2, 1], #s: [0, 1], #SW: [-2, 1], #w: [-2, 0], #NW: [-2, -1]] set convertList to [#NW: #SE, #n: #s, #NE: #SW, #w: #E, #E: #w, #SW: #NE, #s: #n, #SE: #NW] set river1 to the number of cast "C" - 1 set bridge1 to the number of cast "Bridge1" - 1 set rockTile to the number of cast "Rocks" set valleyTile to the number of cast "Valley" set demoFlag to 0 set startSimFlag to 1 set finishedFlag to 1 set adjList to [:] addProp(adjList, "X", [#NW, #n, #NE, #w, #E, #SW, #s, #SE]) addProp(adjList, "N", [#w, #E, #SW, #s, #SE]) addProp(adjList, "N+", [#NW, #NE, #w, #E, #SW, #s, #SE]) addProp(adjList, "NE", [#w, #SW, #s]) addProp(adjList, "NE+", [#NW, #NE, #w, #SW, #s, #SE]) addProp(adjList, "E", [#NW, #n, #w, #SW, #s]) addProp(adjList, "E+", [#NW, #n, #NE, #w, #SW, #s, #SE]) addProp(adjList, "SE", [#NW, #n, #w]) addProp(adjList, "SE+", [#NW, #n, #NE, #w, #SW, #SE]) addProp(adjList, "S", [#NW, #n, #NE, #w, #E]) addProp(adjList, "S+", [#NW, #n, #NE, #w, #E, #SW, #SE]) addProp(adjList, "SW", [#n, #NE, #E]) addProp(adjList, "SW+", [#NW, #n, #NE, #E, #SW, #SE]) addProp(adjList, "W", [#n, #NE, #E, #s, #SE]) addProp(adjList, "W+", [#NW, #n, #NE, #E, #SW, #s, #SE]) addProp(adjList, "NW", [#E, #s, #SE]) addProp(adjList, "NW+", [#NW, #NE, #E, #SW, #s, #SE]) set tileList to [:] addProp(tileList, #n, [#n: 20, #NE: 180, #E: 90, #SE: 140, #s: 20, #SW: 150, #w: 110, #NW: 190]) addProp(tileList, #NE, [#n: 170, #NE: 10, #E: 220, #SE: 60, #s: 150, #SW: 10, #w: 240, #NW: 50]) addProp(tileList, #E, [#n: 100, #NE: 210, #E: 30, #SE: 230, #s: 110, #SW: 240, #w: 30, #NW: 260]) addProp(tileList, #SE, [#n: 130, #NE: 40, #E: 200, #SE: 0, #s: 190, #SW: 50, #w: 260, #NW: 0]) addProp(tileList, #s, [#n: 20, #NE: 120, #E: 80, #SE: 160, #s: 20, #SW: 170, #w: 100, #NW: 130]) addProp(tileList, #SW, [#n: 120, #NE: 10, #E: 270, #SE: 70, #s: 180, #SW: 10, #w: 210, #NW: 40]) addProp(tileList, #w, [#n: 80, #NE: 270, #E: 30, #SE: 250, #s: 90, #SW: 220, #w: 30, #NW: 200]) addProp(tileList, #NW, [#n: 160, #NE: 70, #E: 250, #SE: 0, #s: 140, #SW: 60, #w: 230, #NW: 0]) set riverList to [#E: [#NE: 5, #SE: 6], #NE: [#NE: 2, #SE: 4, #E: 8], #SE: [#NE: 3, #SE: 1, #E: 7]] set bridgeList to [:] addProp(bridgeList, "A", [#NE: [1, #n], #n: [2, #n], #NW: [3, #n], #s: [2, #s], #E: [4, #n], #w: [5, #n]]) addProp(bridgeList, "B", [#n: [7, #n], #SE: [6, #s], #s: [7, #s], #SW: [8, #s], #E: [9, #s], #w: [10, #s]]) addProp(bridgeList, "C", [#n: [12, #n], #s: [12, #s], #E: [13, #E], #w: [13, #w], #NE: [11, #NE], #SW: [11, #SW]]) addProp(bridgeList, "D", [#n: [15, #n], #s: [15, #s], #E: [16, #E], #w: [16, #w], #NW: [14, #NW], #SE: [14, #SE]]) addProp(bridgeList, "E", [#n: [17, #n], #NW: [18, #n], #s: [17, #s], #w: [19, #n]]) addProp(bridgeList, "F", [#n: [20, #n], #SW: [21, #s], #s: [20, #s], #w: [22, #s]]) addProp(bridgeList, "G", [#n: [23, #n], #NE: [24, #n], #s: [23, #s], #E: [25, #n]]) addProp(bridgeList, "H", [#n: [26, #n], #SE: [27, #s], #s: [26, #s], #E: [28, #s]]) return me end on initSizeVariables me initCovList(me) if gridSize = "Small" then set columns to 8 set rows to 10 set cellHeight to 34 set cellWidth to 68 set gridLeft to 47 set gridTop to 20 else set columns to 5 set rows to 6 set cellHeight to 56 set cellWidth to 112 set gridLeft to 39 set gridTop to 23 end if set NW to -1 * columns set n to (-2 * columns) + 1 set NE to (-1 * columns) + 1 set w to -1 set E to 1 set SW to columns - 1 set s to (2 * columns) - 1 set SE to columns set moveList to [#NW: NW, #n: n, #NE: NE, #w: w, #E: E, #SW: SW, #s: s, #SE: SE] set paver1 to the number of cast ("Ntruck" & gridSize) set truck1 to paver1 set roadTile1 to the number of cast ("Tile1" & gridSize) set treeTile to the number of cast ("Trees" & gridSize) set dummyBitmap to the number of cast ("Dummy" & gridSize) set invisibleButHiliteBmap to the number of cast ("InvisibleButHilite" & gridSize) set partialTileList to [:] repeat with dir in arrowList addProp(partialTileList, dir, the number of cast ("Partial" & gridSize & dir)) end repeat set cellHalfH to cellWidth / 2 set cellHalfV to cellHeight / 2 end on initCovList me set covList to [:] if gridSize = "Small" then addProp(covList, "X", [#NW: [-7, -1, 7, 8, -16, -15], #n: [-8, -7, 7, 8, -23, -22], #NE: [-8, -15, 1, 7, 8, -14], #w: [-8, -7, 7, 8, -9, 6], #E: [-8, -7, 7, 8, -6, 9], #SW: [-8, -7, 8, 15, -1, 14], #s: [-8, -7, 8, 7, 22, 23], #SE: [-8, -7, 1, 15, 7, 16]]) addProp(covList, "N", [#w: [8, 7, 6], #E: [7, 8, 9], #SW: [-1, 15, 8, 1, 14], #s: [7, 8, 23, 22], #SE: [7, 15, 1, 16]]) addProp(covList, "N+", [#NW: [-7, -1, 7, 8], #NE: [-8, 1, 7, 8], #w: [-8, -7, 7, 8, -9, 6], #E: [-8, -7, 7, 8, -6, 9], #SW: [-8, -7, 8, 15, -1, 14], #s: [-8, -7, 8, 7, 22, 23], #SE: [-8, -7, 1, 15, 7, 16]]) addProp(covList, "NE", [#w: [7, 6], #SW: [-1, 15, 14], #s: [7, 22]]) addProp(covList, "NE+", [#NW: [-7, -1, 7, 8], #NE: [-8, 7, 8], #w: [-8, -7, 7, 8, -9, 6], #SW: [-8, -7, 8, 15, -1, 14], #s: [-8, -7, 8, 7, 22, 23], #SE: [-8, -7, 15, 7]]) addProp(covList, "E", [#NW: [-1, 7, -16, -15], #n: [-8, 7, -23], #w: [-8, 7, -9, 6], #SW: [-8, 15, -1, 14], #s: [-8, 7, 22]]) addProp(covList, "E+", [#NW: [-7, -1, 7, 8, -16, -15], #n: [-8, -7, 7, 8, -23, -22], #NE: [-8, -15, 7, 8], #w: [-8, -7, 7, 8, -9, 6], #SW: [-8, -7, 8, 15, -1, 14], #s: [-8, -7, 8, 7, 22, 23], #SE: [-8, -7, 15, 7]]) addProp(covList, "SE", [#NW: [-1, -16, -15], #n: [-8, -23], #w: [-8, -9]]) addProp(covList, "SE+", [#NW: [-7, -1, 7, 8, -16, -15], #n: [-8, -7, 7, 8, -23, -22], #NE: [-8, -15, 7, 8], #w: [-8, -7, 7, 8, -9, 6], #SW: [-8, -7, 8, -1], #SE: [-8, -7, 1, 7]]) addProp(covList, "S", [#NW: [-7, -1, -16, -15], #n: [-8, -7, -23, -22], #NE: [-8, -15, 1, -14], #w: [-8, -7, -9], #E: [-8, -7, -6]]) addProp(covList, "S+", [#NW: [-7, -1, 7, 8, -16, -15], #n: [-8, -7, 7, 8, -23, -22], #NE: [-8, -15, 1, 7, 8, -14], #w: [-8, -7, 7, 8, -9, 6], #E: [-8, -7, 7, 8, -6, 9], #SW: [-8, -7, 8, -1], #SE: [-8, -7, 1, 7]]) addProp(covList, "SW", [#n: [-7, -22], #NE: [-15, 1, -14], #E: [-7, -6]]) addProp(covList, "SW+", [#NW: [-7, 7, 8, -15], #n: [-8, -7, 7, 8, -23, -22], #NE: [-8, -15, 1, 7, 8, -14], #E: [-8, -7, 7, 8, -6, 9], #SW: [-8, -7, 8], #SE: [-8, -7, 1, 7]]) addProp(covList, "W", [#n: [-7, 8, -22], #NE: [-15, 1, 8, -14], #E: [-7, 8, -6, 9], #s: [-7, 8, 23], #SE: [-7, 1, 15, 16]]) addProp(covList, "W+", [#NW: [-7, 7, 8, -15], #n: [-8, -7, 7, 8, -23, -22], #NE: [-8, -15, 1, 7, 8, -14], #E: [-8, -7, 7, 8, -6, 9], #SW: [-8, -7, 8, 15], #s: [-8, -7, 8, 7, 22, 23], #SE: [-8, -7, 1, 15, 7, 16]]) addProp(covList, "NW", [#E: [8, 9], #s: [8, 9], #SE: [1, 15, 16]]) addProp(covList, "NW+", [#NW: [-7, 7, 8], #NE: [-8, 1, 7, 8], #E: [-8, -7, 7, 8, -6, 9], #SW: [-8, -7, 8, 15], #s: [-8, -7, 8, 7, 22, 23], #SE: [-8, -7, 1, 15, 7, 16]]) else addProp(covList, "X", [#NW: [-4, -1, 4, 5, -10, -9], #n: [-5, -4, 4, 5, -14, -13], #NE: [-5, -9, 1, 4, 5, -8], #w: [-5, -4, 4, 5, -6, 3], #E: [-5, -4, 4, 5, -3, 6], #SW: [-5, -4, 5, 9, -1, 8], #s: [-5, -4, 5, 4, 13, 14], #SE: [-5, -4, 1, 9, 4, 10]]) addProp(covList, "N", [#w: [5, 4, 3], #E: [4, 5, 6], #SW: [-1, 9, 5, 1, 8], #s: [4, 5, 14, 13], #SE: [4, 9, 1, 10]]) addProp(covList, "N+", [#NW: [-4, -1, 4, 5], #NE: [-5, 1, 4, 5], #w: [-5, -4, 4, 5, -6, 3], #E: [-5, -4, 4, 5, -3, 6], #SW: [-5, -4, 5, 9, -1, 8], #s: [-5, -4, 5, 4, 13, 14], #SE: [-5, -4, 1, 9, 4, 10]]) addProp(covList, "NE", [#w: [4, 3], #SW: [-1, 9, 8], #s: [4, 13]]) addProp(covList, "NE+", [#NW: [-4, -1, 4, 5], #NE: [-5, 4, 5], #w: [-5, -4, 4, 5, -6, 3], #SW: [-5, -4, 5, 9, -1, 8], #s: [-5, -4, 5, 4, 13, 14], #SE: [-5, -4, 9, 4]]) addProp(covList, "E", [#NW: [-1, 4, -10, -9], #n: [-5, 4, -14], #w: [-5, 4, -6, 3], #SW: [-5, 9, -1, 8], #s: [-5, 4, 13]]) addProp(covList, "E+", [#NW: [-4, -1, 4, 5, -10, -9], #n: [-5, -4, 4, 5, -14, -13], #NE: [-5, -9, 4, 5], #w: [-5, -4, 4, 5, -6, 3], #SW: [-5, -4, 5, 9, -1, 8], #s: [-5, -4, 5, 4, 13, 14], #SE: [-5, -4, 9, 4]]) addProp(covList, "SE", [#NW: [-1, -10, -9], #n: [-5, -14], #w: [-5, -6]]) addProp(covList, "SE+", [#NW: [-4, -1, 4, 5, -10, -9], #n: [-5, -4, 4, 5, -14, -13], #NE: [-5, -9, 4, 5], #w: [-5, -4, 4, 5, -6, 3], #SW: [-5, -4, 5, -1], #SE: [-5, -4, 1, 4]]) addProp(covList, "S", [#NW: [-4, -1, -10, -9], #n: [-5, -4, -14, -13], #NE: [-5, -9, 1, -8], #w: [-5, -4, -6], #E: [-5, -4, -3]]) addProp(covList, "S+", [#NW: [-4, -1, 4, 5, -10, -9], #n: [-5, -4, 4, 5, -14, -13], #NE: [-5, -9, 1, 4, 5, -8], #w: [-5, -4, 4, 5, -6, 3], #E: [-5, -4, 4, 5, -3, 6], #SW: [-5, -4, 5, -1], #SE: [-5, -4, 1, 4]]) addProp(covList, "SW", [#n: [-4, -13], #NE: [-9, 1, -8], #E: [-4, -3]]) addProp(covList, "SW+", [#NW: [-4, 4, 5, -9], #n: [-5, -4, 4, 5, -14, -13], #NE: [-5, -9, 1, 4, 5, -8], #E: [-5, -4, 4, 5, -3, 6], #SW: [-5, -4, 5], #SE: [-5, -4, 1, 4]]) addProp(covList, "W", [#n: [-4, 5, -13], #NE: [-9, 1, 5, -8], #E: [-4, 5, -3, 6], #s: [-4, 5, 14], #SE: [-4, 1, 9, 10]]) addProp(covList, "W+", [#NW: [-4, 4, 5, -9], #n: [-5, -4, 4, 5, -14, -13], #NE: [-5, -9, 1, 4, 5, -8], #E: [-5, -4, 4, 5, -3, 6], #SW: [-5, -4, 5, 9], #s: [-5, -4, 5, 4, 13, 14], #SE: [-5, -4, 1, 9, 4, 10]]) addProp(covList, "NW", [#E: [5, 6], #s: [5, 6], #SE: [1, 9, 10]]) addProp(covList, "NW+", [#NW: [-4, 4, 5], #NE: [-5, 1, 4, 5], #E: [-5, -4, 4, 5, -3, 6], #SW: [-5, -4, 5, 9], #s: [-5, -4, 5, 4, 13, 14], #SE: [-5, -4, 1, 9, 4, 10]]) end if end on initializeGrid me set gridLeft2 to gridLeft + cellHalfH set gridTop2 to gridTop + cellHalfV set maxX to gridLeft + ((columns - 1) * cellWidth) set maxY to gridTop + ((rows - 1) * cellHeight) set cellList to [] set cell to 1 set vertVal to 1 add(cellList, birth(script "Cell Parent", cell, "NW", gridLeft, gridTop, 1, vertVal)) set cell to cell + 1 repeat with x = 1 to columns - 2 add(cellList, birth(script "Cell Parent", cell, "N", gridLeft + (x * cellWidth), gridTop, ((x + 1) * 2) - 1, vertVal)) set cell to cell + 1 end repeat add(cellList, birth(script "Cell Parent", cell, "NE", maxX, gridTop, (columns * 2) - 1, vertVal)) set cell to cell + 1 set vertVal to 2 add(cellList, birth(script "Cell Parent", cell, "NW+", gridLeft2, gridTop2, 2, vertVal)) set cell to cell + 1 repeat with x = 1 to columns - 3 add(cellList, birth(script "Cell Parent", cell, "N+", gridLeft2 + (x * cellWidth), gridTop2, (x + 1) * 2, vertVal)) set cell to cell + 1 end repeat add(cellList, birth(script "Cell Parent", cell, "NE+", maxX - cellHalfH, gridTop2, (columns - 1) * 2, vertVal)) set cell to cell + 1 set curV to gridTop + cellHalfH set rowOddEven to 1 repeat with vertVal = 3 to (rows * 2) - 3 if rowOddEven = 1 then add(cellList, birth(script "Cell Parent", cell, "W", gridLeft, curV, 1, vertVal)) set cell to cell + 1 repeat with y = 1 to columns - 2 add(cellList, birth(script "Cell Parent", cell, "X", gridLeft + (y * cellWidth), curV, ((y + 1) * 2) - 1, vertVal)) set cell to cell + 1 end repeat add(cellList, birth(script "Cell Parent", cell, "E", maxX, curV, (columns * 2) - 1, vertVal)) set cell to cell + 1 set rowOddEven to 0 else add(cellList, birth(script "Cell Parent", cell, "W+", gridLeft + cellHalfH, curV, 2, vertVal)) set cell to cell + 1 repeat with y = 1 to columns - 3 add(cellList, birth(script "Cell Parent", cell, "X", gridLeft2 + (y * cellWidth), curV, (y + 1) * 2, vertVal)) set cell to cell + 1 end repeat add(cellList, birth(script "Cell Parent", cell, "E+", maxX - cellHalfH, curV, (columns - 1) * 2, vertVal)) set cell to cell + 1 set rowOddEven to 1 end if set curV to curV + cellHalfV end repeat set vertVal to (rows * 2) - 2 add(cellList, birth(script "Cell Parent", cell, "SW+", gridLeft2, maxY - cellHalfV, 2, vertVal)) set cell to cell + 1 repeat with x = 1 to columns - 3 add(cellList, birth(script "Cell Parent", cell, "S+", gridLeft2 + (x * cellWidth), maxY - cellHalfV, (x + 1) * 2, vertVal)) set cell to cell + 1 end repeat add(cellList, birth(script "Cell Parent", cell, "SE+", maxX - cellHalfH, maxY - cellHalfV, (columns - 1) * 2, vertVal)) set cell to cell + 1 set vertVal to (rows * 2) - 1 add(cellList, birth(script "Cell Parent", cell, "SW", gridLeft, maxY, 1, vertVal)) set cell to cell + 1 repeat with x = 1 to columns - 2 add(cellList, birth(script "Cell Parent", cell, "S", gridLeft + (x * cellWidth), maxY, ((x + 1) * 2) - 1, vertVal)) set cell to cell + 1 end repeat add(cellList, birth(script "Cell Parent", cell, "SE", maxX, maxY, (columns * 2) - 1, vertVal)) end on newTruck set adjacentCellList to the adjacentList of getAt(cellList, startCell) set direction to getAt(adjacentCellList, random(count(adjacentCellList))) set firstCell to startCell + getProp(moveList, direction) initTruckProps(gTruckObject, firstCell, direction) set cellObj to getAt(cellList, startCell) set startName to getAt(scenarioData, 1) set startTile to the number of cast (startName & "." & gridSize) set startRoadtile to startTile + 8 + getPos(arrowList, direction) set the tileNum of cellObj to startRoadtile set the tileType of cellObj to #Goal set the startTileNum of cellObj to startRoadtile set the startTileType of cellObj to #Goal end on placeGoals set goalCell to random(columns) if gridSize = "Small" then if goalCell > 4 then set startCell to random(4) + 135 else set startCell to random(4) + 139 end if else if goalCell > 3 then set startCell to random(3) + 45 else set startCell to random(2) + 48 end if end if set cellObj to getAt(cellList, goalCell) set goalName to getAt(scenarioData, 6) set goalTile to the number of cast (goalName & "." & gridSize) set the tileNum of cellObj to goalTile set the tileType of cellObj to #Goal set the startTileNum of cellObj to goalTile set the startTileType of cellObj to #Goal end on erasePlayfield me global gGasGaugeObject, gLevelObject if the level of gLevelObject = 3 then set the currentV of gGasGaugeObject to the maxV of gGasGaugeObject updateGasGauge(gGasGaugeObject) end if set the locH of sprite underTruckSprite to 1000 set the locH of sprite destinationSprite to 1000 set the locH of sprite truckSprite to 1000 set the locH of sprite stampSprite to the locH of sprite gridSprite set the locV of sprite stampSprite to the locV of sprite gridSprite set the castNum of sprite stampSprite to the castNum of sprite gridSprite updateStage() clearCoverTiles() set the castNum of sprite stampSprite to 0 set the locH of sprite stampSprite to 1000 updateStage() end on newGame me set scenarioData to getAt(scenarioList, random(count(scenarioList))) set returnVehicle to the number of cast (getAt(scenarioData, 7) & gridSize) set scenarioSong to getAt(scenarioData, 8) set finishedFlag to 0 set startSimFlag to 1 set demoFlag to 0 set buildingsConnected to 0 placeGoals() newTruck() if the level of gLevelObject = 1 then set pathList to placeBuildings() placeObstacle([#immovable, treeTile, 6, 40]) else if the level of gLevelObject = 2 then set pathList to placeBuildings() placeObstacle([#immovable, treeTile, 6, #Rocks, rockTile, 3, 40]) else drawRiver() set pathList to placeBuildings() resetGasGauge(gGasGaugeObject, count(pathList)) placeObstacle([#immovable, treeTile, 6, #Rocks, rockTile, 3, #Valley, valleyTile, 1, 40]) end if end if removeMessage() set availableMoveList to createAvailableList(gTruckObject, the cell of gTruckObject) refreshControls(availableMoveList) placeInvisibleButtons(me, availableMoveList) redrawBG(me) drawTruck(gTruckObject) simIntroSong() end on initializeSimButtons me if firstTime = 1 then repeat with x = 1 to count(arrowList) set channel to firstNavButtonChan + x - 1 addProp(simButtonList, getAt(arrowList, x), birth(script "Button Parent", channel, the locH of sprite channel, the locV of sprite channel, the castNum of sprite channel, 1)) end repeat addProp(simButtonList, #Demo, birth(script "Button Parent", demoButChan, the locH of sprite demoButChan, the locV of sprite demoButChan, the castNum of sprite demoButChan, 1)) addProp(simButtonList, #alert, birth(script "Button Parent", 48, the locH of sprite 48, the locH of sprite 48, the castNum of sprite 48, 0)) set firstTime to 0 end if end on hideSprites me set the locH of sprite underTruckSprite to the locH of sprite underTruckSprite + 1000 puppetSprite(underTruckSprite, 1) set the locH of sprite destinationSprite to the locH of sprite destinationSprite + 1000 puppetSprite(destinationSprite, 1) set channel to the channel of gTruckObject set the locH of sprite channel to the locH of sprite channel + 1000 puppetSprite(channel, 1) end on redrawBG me repeat with x = 1 to count(cellList) set cellObj to getAt(cellList, x) redrawCell(cellObj, stampSprite) updateStage() end repeat end on isRoadFinished me set truck1 to paver1 if finishedFlag = 1 then if demoFlag <> 1 then if buildingsConnected = (the level of gLevelObject + 1) then roadCongrats() set buildingsConnected to 0 simAward(gAwardsObject) unpuppetAll() keepSandboxBut(sandboxChan) puppetPalette("SimPal") go("Grass") unLoadCast() go(the frame + 1) puppetPalette("AwardsPal", 60) updateStage() puppetPalette(0) predraw(gAwardsObject) go("SimAward") puppetSprite(48, 0) else sound playFile 1, gCDpath & "SOUND" & gFileSep & "SIM" & gFileSep & "10VOBLDG" set buildingsConnected to 0 repeat while soundBusy(1) end repeat afterPlayback() end if else afterPlayback() end if end if end on puppetTruckSprites me, trueOrFalse puppetSprite(underTruckSprite, trueOrFalse) puppetSprite(destinationSprite, trueOrFalse) puppetSprite(truckSprite, trueOrFalse) end on predrawSimButtons me repeat with x = 1 to count(simButtonList) set buttonObject to getAt(simButtonList, x) set channel to the channel of buttonObject set the castNum of sprite channel to the bmap of buttonObject if the available of buttonObject = 1 then set the locH of sprite channel to the locH of buttonObject else set the locH of sprite channel to 1000 end if set the locV of sprite channel to the locV of buttonObject puppetSprite(channel, 1) end repeat if the level of gLevelObject = 3 then predrawGasGauge(gGasGaugeObject) end if end on lightButton me, moveName set buttonChannel to the channel of getProp(simButtonList, moveName) set the castNum of sprite buttonChannel to the castNum of sprite buttonChannel + 1 updateStage() end on unlightButton me, moveName set buttonChannel to the channel of getProp(simButtonList, moveName) set the castNum of sprite buttonChannel to the castNum of sprite buttonChannel - 1 updateStage() end on placeInvisibleButtons me, availableList, surroundFlag if not (demoFlag or the playBack of gTruckObject) then clearCoverTiles() updateStage() set truckCell to the cell of gTruckObject repeat with x = 1 to count(invisibleButtonList) set vector to getAt(arrowList, x) if getPos(availableList, vector) <> 0 then set channel to firstInvisButChan + x - 1 set cell to getAt(invisibleButtonList, x) set newCell to truckCell + getProp(moveList, vector) set cellObj to getAt(cellList, newCell) if surroundFlag = 1 then surroundStaticSprite(me, newCell, truckCell) updateStage() end if set the locH of sprite channel to the Xloc of cellObj set the locV of sprite channel to the Yloc of cellObj updateStage() setAt(invisibleButtonList, x, newCell) next repeat end if setAt(invisibleButtonList, x, 0) end repeat end if end on replaceInvisibleButtons me clearCoverTiles() updateStage() set truckCell to the cell of gTruckObject repeat with x = 1 to count(invisibleButtonList) set vector to getAt(arrowList, x) if getAt(invisibleButtonList, x) <> 0 then set channel to firstInvisButChan + x - 1 set cell to getAt(invisibleButtonList, x) set newCell to truckCell + getProp(moveList, vector) set cellObj to getAt(cellList, newCell) surroundStaticSprite(me, newCell, truckCell) set the locH of sprite channel to the Xloc of cellObj set the locV of sprite channel to the Yloc of cellObj updateStage() end if end repeat end on hideInvisibleButtons me repeat with x = 1 to count(invisibleButtonList) set cell to getAt(invisibleButtonList, x) if cell <> 0 then set cellObj to getAt(cellList, cell) surroundStaticSprite(me, cell, the cell of gTruckObject) updateStage() set channel to firstInvisButChan + x - 1 set the locH of sprite channel to 1000 updateStage() end if end repeat end on surroundStaticSprite me, cellNum, protectedCell set cellObj to getAt(cellList, cellNum) set coverList to [] set adjacentList to getProp(adjList, the cellType of cellObj) repeat with vector in [#NW, #NE, #SE, #SW] if getPos(adjacentList, vector) <> 0 then if (cellNum + getProp(moveList, vector)) <> protectedCell then add(coverList, vector) end if end if end repeat if cellNum <> protectedCell then redrawCell(getAt(cellList, cellNum), firstSurroundSprite) updateStage() end if repeat with x = 1 to count(coverList) set vector to getAt(coverList, x) set adjCell to cellNum + getProp(moveList, vector) redrawCell(getAt(cellList, adjCell), firstSurroundSprite + x) end repeat updateStage() end on fixTile me set the locH of sprite stampSprite to the locH of sprite underTruckSprite set the locV of sprite stampSprite to the locV of sprite underTruckSprite set the castNum of sprite stampSprite to the castNum of sprite underTruckSprite updateStage() end on loadSim me, index set dataCounter to index set firstTime to readData(me) if firstTime = 0 then repeat with cellObj in cellList loadCell(cellObj) end repeat set recordedMoveList to [] set moveListLength to readData(me) repeat with x = 1 to moveListLength set oneMove to getAt(arrowList, readData(me)) add(recordedMoveList, oneMove) end repeat set startSimFlag to readData(me) set finishedFlag to readData(me) set pathCount to readData(me) set pathList to [:] repeat with x = 1 to pathCount set propName to getAt(arrowList, readData(me)) set cellNum to readData(me) addProp(pathList, propName, cellNum) end repeat set startCell to readData(me) set goalCell to readData(me) set simButtonList to [#n: 0, #NE: 0, #E: 0, #SE: 0, #s: 0, #SW: 0, #w: 0, #NW: 0, #Demo: 0, #alert: 0] repeat with x = 1 to count(simButtonList) set avail to readData(me) set chanNum to readData(me) set Xloc to readData(me) set Yloc to readData(me) set bmap to readData(me) setAt(simButtonList, x, birth(script "Button Parent", chanNum, Xloc, Yloc, bmap, avail)) end repeat set buildingsConnected to readData(me) set returnVehicle to readData(me) end if return dataCounter end on saveSim me set simDataString to EMPTY appendData(me, firstTime) if firstTime = 0 then repeat with cellObject in cellList appendData(me, saveCell(cellObject)) end repeat appendData(me, count(recordedMoveList)) repeat with vector in recordedMoveList appendData(me, getPos(arrowList, vector)) end repeat appendData(me, startSimFlag) appendData(me, finishedFlag) appendData(me, count(pathList)) repeat with x = 1 to count(pathList) appendData(me, getPos(arrowList, getPropAt(pathList, x))) appendData(me, getAt(pathList, x)) end repeat appendData(me, startCell) appendData(me, goalCell) repeat with buttonObject in simButtonList appendData(me, saveButton(buttonObject)) end repeat appendData(me, buildingsConnected) appendData(me, returnVehicle) end if set simData to simDataString set simDataString to EMPTY return simData end on setup me preloadVehicle(gTruckObject, truck1) if demoFlag <> 1 then createGlobalButtons(me) end if initializeSimButtons(me) if obstacleState = EMPTY then if finishedFlag = 1 then newGameAlert() updateStage() initializeGrid(me) newGame(me) else set availableMoveList to createAvailableList(gTruckObject, the cell of gTruckObject) placeInvisibleButtons(me, availableMoveList, 0) redrawBG(me) drawTruck(gTruckObject) refreshControls(availableMoveList) end if else redrawBG(me) surroundSprite(the cell of gTruckObject, the newMove of gTruckObject) set the locH of sprite underTruckSprite to the locH of sprite underTruckSprite - 1000 set the castNum of sprite destinationSprite to the tileNum of the blockedCellObj of gTruckObject set the locH of sprite destinationSprite to the locH of sprite destinationSprite - 1000 restore(gTruckObject) updateStage() if (obstacleState = #Rocks) or (obstacleState = #Valley) then part2ofMove(gTruckObject) set obstacleState to EMPTY else if obstacleState = #River then set the programmedMove of gTruckObject to #enterBridge part2ofMove(gTruckObject) set obstacleState to EMPTY puppetAll() go(the frame) exit end if end if end if puppetAll() end on createGlobalButtons me add(gActorList, birth(script "Rollover Anim Button Class", "goMenu( gSimObject, me )", 27, 27, 5, "RCA-07VO01", "RCA-07RO01")) add(gActorList, birth(script "Rollover Anim Button Class", "help( gSimObject, me )", 28, 28, 11, EMPTY, "RCA-05RO02")) end on forgetObstacle me deleteAt(recordedMoveList, count(recordedMoveList)) set cellObj to the cellObject of gTruckObject if the tileType of cellObj = #Bridge then checkForBridge(gTruckObject, cellObj) end if set the newMove of gTruckObject to getLast(recordedMoveList) set the lastMove of gTruckObject to getLast(recordedMoveList) set partialTile to getProp(partialTileList, the newMove of gTruckObject) set cellObj to the cellObject of gTruckObject set the tileNum of cellObj to partialTile + the connector of cellObj set obstacleState to EMPTY end on goMenu me, buttonObject clearAllActors() makeButtonJump(buttonObject) puppetPalette("SimPal") unpuppetAll() go("Grass") unLoadCast() go(the frame + 1) goLocationMap() end on appendData me, datum set simDataString to simDataString & string(datum) & "," end on readData me set datum to value(item dataCounter of the dataString of gMenuObject) set dataCounter to dataCounter + 1 return datum end on help me, buttonObject birth(script "Help Parent", buttonObject, "Sim" & the level of gLevelObject) end